﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 索引器02
{
    class Program
    {
        static void Main(string[] args)
        {
            // 创建一个索引器，对类里面的字典进行数据的存取，用来记录学生的姓名和分数

            StudentChineseScore scs = new StudentChineseScore();
            scs["xiaoming"] = 85;
            scs["xiaoliang"] = 55;
            scs["xiaohong"] = 98;
            scs["me"] = 100;

            Console.WriteLine(scs["xiaoming"]);
            Console.WriteLine(scs["xiaoliang"]);
            Console.WriteLine(scs["xiaohong"]);
            Console.WriteLine(scs["me"]);
        }
    }

    class StudentChineseScore
    {
        private Dictionary<string, int> chineseScores = new Dictionary<string, int>();
        public int this[string indexName]
        {
            get
            {
                return chineseScores[indexName];
            }
            set
            {
                chineseScores.Add(indexName, value);
            }
        }
    }
}
